#include <stdio.h>

int main()
{
    char p1[100], p2[100];
    while (scanf("%s %s", p1, p2) && p1[0] != 'E')
    {
        int w1 = 0, w2 = 0, i;
        char c1, c2;
        for (i = 0; (c1 = p1[i]) && (c2 = p2[i]); i++)
        {
            w1 += (c1=='R' && c2=='S' || c1=='S' && c2=='P' || c1=='P' && c2=='R');
            w2 += (c2=='R' && c1=='S' || c2=='S' && c1=='P' || c2=='P' && c1=='R');
        }
        printf("P1: %d\n", w1);
        printf("P2: %d\n", w2);
    }
    return 0;
}
